//
//  PaperInputSelectionCell.m
//  DoingPaper
//
//  Created by zhuxuhong on 16/7/27.
//  Copyright © 2016年 zhuxuhong. All rights reserved.
//

#import "PaperInputSelectionCell.h"
#import "DoingPaperMainController.h"
#import "InputView.h"

@interface PaperInputSelectionCell()<InputViewDelegate>

@property(nonatomic,strong)InputView *inputView;

@end

@implementation PaperInputSelectionCell
{
    CGSize cellSize;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.5];
        
        _inputView = [[InputView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth([UIScreen mainScreen].bounds), 200) delegate:self placeholder:@"输入答案..." returnKeyType:UIReturnKeyNext];
        
        [self addSubview:_inputView];
    }
    return self;
}

// setters
-(void)setQuestion:(PaperQuestion *)question{
    if (question) {
        // 更新输入的内容
        [_inputView setInputedText: question.userAnswer];
        // 是否交卷
        [_inputView setInputable: !question.submited];
        _question = question;
    }
}

-(void)inputViewDidClickedReturnButton{
    // 下一页 - 通知
    [[NSNotificationCenter defaultCenter]postNotificationName:@"DidSelectOptionNoti" object:nil];
}

-(void)inputViewDidEndInputingWithText:(NSString *)inputedText{
    _question.userAnswer = inputedText;
}

@end
